Updating Job Object Information
When you receive a resume event, you should use theGXUpdateJob
function to update the job object because the printing environment may have changed while the user was switched out of your application. For example, the user may have changed the desktop printer's settings, such as paper-tray information, while using another application.Listing 2-17 shows an example of how to update the job object for a document. The
GXUpdateJob
function is called from the MyDoEvent function in response to a resume event.Listing 2-17 Updating a job when receiving resume events
OSErr MyDoEvent(EventRecord *event) { OSErr err = noErr; WindowPtr curWindow; MyDocumentPtr windowDoc; switch (event->what) { /* Application-specific code to handle mouse-down events, update events, and so on. */ case osEvt: switch ((event->message >> 24) & 0x0FF) { case suspendResumeMessage: SetCursor(&qd.arrow); /* On a suspend event, coerce the scrap. */ if ((event->message & resumeFlag) == 0) { ZeroScrap(); TEToScrap(); } else { /* On a resume event, call GXUpdateJob on all of the documents' job objects. The user may have just changed something which affects the job objects, such as the size of the paper in the printer. Since your application stores the document pointers in the reference constant fields of the documents' windows, loop through each window, extract the document pointers, and update the associated job objects. */ if (event->message & convertClipboardFlag) TEFromScrap(); curWindow = FrontWindow(); while (curWindow != nil) { if (((WindowPeek) curWindow)->windowKind == userKind) { windowDoc = (MyDocumentPtr) GetWRefCon(curWindow); GXUpdateJob(windowDoc->documentJob); } curWindow = (WindowPtr) ((WindowPeek) curWindow)->nextWindow; } } break; } break; /* Application-specific code to handle high-level events. */ } return err; }
Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help